/*
 * Copyright 2017-8-30 13:56:25 The JA-SIG Collaborative. All rights reserved.
 * distributed with thi file and available online at
 */
package com.lap.scp.admin.core.impl;

import java.util.Collections;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lap.scd.commons.core.exception.ManagerException;
import com.lap.scd.commons.page.Page;
import com.lap.scp.admin.core.ConfigManager;
import com.lap.scp.admin.dal.ConfigDAO;
import com.lap.scp.admin.domain.ConfigDO;
import com.lap.scp.admin.query.ConfigQueryDO;

/**
 * <pre>
 *  //TODO 注释
 * </pre>
 * 
 * @author 系统自动生成 Exp
 * @Date 2017-8-30 13:56:25
 * @since 1.0
 */
@Service("configManager")
public class DefaultConfigManager implements ConfigManager {

    @Resource
    private ConfigDAO configDAO;

    
    @Override
    public int deleteById(int configId) throws ManagerException {
        return configDAO.deleteById(configId);
    }
    
    @Override
    public void insertConfig(ConfigDO configDO) throws ManagerException {
       configDAO.insertConfig(configDO);
    }
    
    @Override
    public ConfigDO queryById(int configId) throws ManagerException {
        return configDAO.queryById(configId);
    }
    
    @Override
    public List<ConfigDO> queryPage(Page page, ConfigQueryDO queryDO) throws ManagerException {
        int count = configDAO.countPage(queryDO);
        if(count<=0){
          return Collections.emptyList();
        }else {
          page.setTotalItem(count);
          return configDAO.queryPage(page,queryDO);
        }
    }
    
    @Override
    public int updateConfig(ConfigDO configDO) throws ManagerException {
        return configDAO.updateConfig(configDO);
    }

}
